home *** CD-ROM | disk | FTP | other *** search
/ Amiga Plus 1999 #3 / Amiga Plus CD - 1999 - No. 3.iso / System / delitracker_ii / developer / examples / custom_nt.s next >
Text File  |  1994-04-10  |  9KB  |  558 lines

  1.  
  2.     incdir    "Includes:"
  3.     include    "misc/DeliPlayer.i"
  4.  
  5. ;
  6. ;
  7.     SECTION Player,Code
  8. ;
  9. ;
  10.  
  11.     PLAYERHEADER PlayerTagArray
  12.  
  13.     dc.b '$VER: sample custom player module V1.0 (30 Mar 92)',0
  14.     even
  15.  
  16. PlayerTagArray
  17.     dc.l    DTP_CustomPlayer,1        ; CustomPlayer - Tag (important !!!)
  18.     dc.l    DTP_Interrupt,mt_music
  19.     dc.l    DTP_InitPlayer,InitPly
  20.     dc.l    DTP_EndPlayer,EndPly
  21.     dc.l    DTP_InitSound,mt_init
  22.     dc.l    DTP_EndSound,mt_end
  23.     dc.l    TAG_DONE
  24.  
  25. *-----------------------------------------------------------------------*
  26. ;
  27. ; Init Player
  28.  
  29. InitPly
  30.     move.l    dtg_AudioAlloc(a5),a0        ; Function
  31.     jsr    (a0)
  32.     rts
  33.  
  34. *-----------------------------------------------------------------------*
  35. ;
  36. ; End Player
  37.  
  38. EndPly
  39.     move.l    dtg_AudioFree(a5),a0        ; Function
  40.     jsr    (a0)
  41.     rts
  42.  
  43. *-----------------------------------------------------------------------*
  44. ;
  45. ; NoiseTracker-Replay
  46.  
  47. ;­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­
  48. ;­   NoisetrackerV2.0 Normal replay   ­
  49. ;­     Uses registers d0-d3/a0-a5     ­
  50. ;­ Mahoney & Kaktus - (C) E.A.S. 1990 ­
  51. ;­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­
  52.  
  53. mt_init:
  54.     movem.l    d0-d2/a0-a2,-(a7)
  55.     lea    mt_data,a0
  56.     lea    $3b8(a0),a1
  57.     moveq    #$7f,d0
  58.     moveq    #0,d2
  59.     moveq    #0,d1
  60. mt_lop2:move.b    (a1)+,d1
  61.     cmp.b    d2,d1
  62.     ble.s    mt_lop
  63.     move.l    d1,d2
  64. mt_lop:    dbf    d0,mt_lop2
  65.     addq.b    #1,d2
  66.  
  67.     asl.l    #8,d2
  68.     asl.l    #2,d2
  69.     lea    4(a1,d2.l),a2
  70.     lea    mt_samplestarts(pc),a1
  71.     add.w    #42,a0
  72.     moveq    #$1e,d0
  73. mt_lop3:clr.l    (a2)
  74.     move.l    a2,(a1)+
  75.     moveq    #0,d1
  76.     move.w    (a0),d1
  77.     asl.l    #1,d1
  78.     add.l    d1,a2
  79.     add.l    #$1e,a0
  80.     dbf    d0,mt_lop3
  81.  
  82. ;    or.b    #2,$bfe001
  83.     move.b    #6,mt_speed
  84.     moveq    #0,d0
  85.     lea    $dff000,a0
  86.     move.w    d0,$a8(a0)
  87.     move.w    d0,$b8(a0)
  88.     move.w    d0,$c8(a0)
  89.     move.w    d0,$d8(a0)
  90.     clr.b    mt_songpos
  91.     clr.b    mt_counter
  92.     clr.w    mt_pattpos
  93.     movem.l    (a7)+,d0-d2/a0-a2
  94.     rts
  95.  
  96. mt_end:
  97.     clr.w    $dff0a8
  98.     clr.w    $dff0b8
  99.     clr.w    $dff0c8
  100.     clr.w    $dff0d8
  101.     move.w    #$f,$dff096
  102.     rts
  103.  
  104.  
  105. mt_music:
  106.     movem.l    d0-d3/a0-a5,-(a7)
  107.     lea    mt_data,a0
  108.     addq.b    #1,mt_counter
  109.     move.b    mt_counter(pc),d0
  110.     cmp.b    mt_speed(pc),d0
  111.     blt    mt_nonew
  112.     clr.b    mt_counter
  113.  
  114.     lea    mt_data,a0
  115.     lea    $c(a0),a3
  116.     lea    $3b8(a0),a2
  117.     lea    $43c(a0),a0
  118.  
  119.     moveq    #0,d0
  120.     moveq    #0,d1
  121.     move.b    mt_songpos(pc),d0
  122.     move.b    (a2,d0.w),d1
  123.     lsl.w    #8,d1
  124.     lsl.w    #2,d1
  125.     add.w    mt_pattpos(pc),d1
  126.     clr.w    mt_dmacon
  127.  
  128.     lea    $dff0a0,a5
  129.     lea    mt_voice1(pc),a4
  130.     bsr    mt_playvoice
  131.     addq.l    #4,d1
  132.     lea    $dff0b0,a5
  133.     lea    mt_voice2(pc),a4
  134.     bsr    mt_playvoice
  135.     addq.l    #4,d1
  136.     lea    $dff0c0,a5
  137.     lea    mt_voice3(pc),a4
  138.     bsr    mt_playvoice
  139.     addq.l    #4,d1
  140.     lea    $dff0d0,a5
  141.     lea    mt_voice4(pc),a4
  142.     bsr    mt_playvoice
  143.  
  144.     move.w    mt_dmacon(pc),d0
  145.     beq.s    mt_nodma
  146.  
  147.     bsr    mt_wait
  148.     or.w    #$8000,d0
  149.     move.w    d0,$dff096
  150.     bsr    mt_wait
  151. mt_nodma:
  152.     lea    mt_voice1(pc),a4
  153.     lea    $dff000,a3
  154.     move.l    $a(a4),$a0(a3)
  155.     move.w    $e(a4),$a4(a3)
  156.     move.l    $a+$1c(a4),$b0(a3)
  157.     move.w    $e+$1c(a4),$b4(a3)
  158.     move.l    $a+$38(a4),$c0(a3)
  159.     move.w    $e+$38(a4),$c4(a3)
  160.     move.l    $a+$54(a4),$d0(a3)
  161.     move.w    $e+$54(a4),$d4(a3)
  162.  
  163.     add.w    #$10,mt_pattpos
  164.     cmp.w    #$400,mt_pattpos
  165.     bne.s    mt_exit
  166. mt_next:clr.w    mt_pattpos
  167.     clr.b    mt_break
  168.     addq.b    #1,mt_songpos
  169.     and.b    #$7f,mt_songpos
  170.     move.b    -2(a2),d0
  171.     cmp.b    mt_songpos(pc),d0
  172.     bne.s    mt_exit
  173.     move.b    -1(a2),mt_songpos
  174. mt_exit:tst.b    mt_break
  175.     bne.s    mt_next
  176.     movem.l    (a7)+,d0-d3/a0-a5
  177.     rts
  178.  
  179. mt_wait:moveq    #3,d3
  180. mt_wai2:move.b    $dff006,d2
  181. mt_wai3:cmp.b    $dff006,d2
  182.     beq.s    mt_wai3
  183.     dbf    d3,mt_wai2
  184.     moveq    #8,d2
  185. mt_wai4:dbf    d2,mt_wai4
  186.     rts
  187.  
  188. mt_nonew:
  189.     lea    mt_voice1(pc),a4
  190.     lea    $dff0a0,a5
  191.     bsr    mt_com
  192.     lea    mt_voice2(pc),a4
  193.     lea    $dff0b0,a5
  194.     bsr    mt_com
  195.     lea    mt_voice3(pc),a4
  196.     lea    $dff0c0,a5
  197.     bsr    mt_com
  198.     lea    mt_voice4(pc),a4
  199.     lea    $dff0d0,a5
  200.     bsr    mt_com
  201.     bra.s    mt_exit
  202.  
  203. mt_mulu:
  204.     dc.w $000,$01e,$03c,$05a,$078,$096,$0b4,$0d2,$0f0,$10e,$12c,$14a
  205.     dc.w $168,$186,$1a4,$1c2,$1e0,$1fe,$21c,$23a,$258,$276,$294,$2b2
  206.     dc.w $2d0,$2ee,$30c,$32a,$348,$366,$384,$3a2
  207.  
  208. mt_playvoice:
  209.     move.l    (a0,d1.l),(a4)
  210.     moveq    #0,d2
  211.     move.b    2(a4),d2
  212.     lsr.b    #4,d2
  213.     move.b    (a4),d0
  214.     and.b    #$f0,d0
  215.     or.b    d0,d2
  216.     beq.s    mt_oldinstr
  217.  
  218.     lea    mt_samplestarts-4(pc),a1
  219.     asl.w    #2,d2
  220.     move.l    (a1,d2.l),4(a4)
  221.     lsr.w    #1,d2
  222.     move.w    mt_mulu(pc,d2.w),d2
  223.     move.w    (a3,d2.w),8(a4)
  224.     move.w    2(a3,d2.w),$12(a4)
  225.     moveq    #0,d3
  226.     move.w    4(a3,d2.w),d3
  227.     tst.w    d3
  228.     beq.s    mt_noloop
  229.     move.l    4(a4),d0
  230.     asl.w    #1,d3
  231.     add.l    d3,d0
  232.     move.l    d0,$a(a4)
  233.     move.w    4(a3,d2.w),d0
  234.     add.w    6(a3,d2.w),d0
  235.     move.w    d0,8(a4)
  236.     bra.s    mt_hejaSverige
  237. mt_noloop:
  238.     move.l    4(a4),d0
  239.     add.l    d3,d0
  240.     move.l    d0,$a(a4)
  241. mt_hejaSverige:
  242.     move.w    6(a3,d2.w),$e(a4)
  243.     moveq    #0,d0
  244.     move.b    $13(a4),d0
  245.     move.w    d0,8(a5)
  246.  
  247. mt_oldinstr:
  248.     move.w    (a4),d0
  249.     and.w    #$fff,d0
  250.     beq    mt_com2
  251.     tst.w    8(a4)
  252.     beq.s    mt_stopsound
  253.     tst.b    $12(a4)
  254.     bne.s    mt_stopsound
  255.     move.b    2(a4),d0
  256.     and.b    #$f,d0
  257.     cmp.b    #5,d0
  258.     beq.s    mt_setport
  259.     cmp.b    #3,d0
  260.     beq.s    mt_setport
  261.  
  262.     move.w    (a4),$10(a4)
  263.     and.w    #$fff,$10(a4)
  264.     move.w    $1a(a4),$dff096
  265.     clr.b    $19(a4)
  266.  
  267.     move.l    4(a4),(a5)
  268.     move.w    8(a4),4(a5)
  269.     move.w    $10(a4),6(a5)
  270.  
  271.     move.w    $1a(a4),d0    ;dmaset
  272.     or.w    d0,mt_dmacon
  273.     bra    mt_com2
  274.  
  275. mt_stopsound:
  276.     move.w    $1a(a4),$dff096
  277.     bra    mt_com2
  278.  
  279. mt_setport:
  280.     move.w    (a4),d2
  281.     and.w    #$fff,d2
  282.     move.w    d2,$16(a4)
  283.     move.w    $10(a4),d0
  284.     clr.b    $14(a4)
  285.     cmp.w    d0,d2
  286.     beq.s    mt_clrport
  287.     bge    mt_com2
  288.     move.b    #1,$14(a4)
  289.     bra    mt_com2
  290. mt_clrport:
  291.     clr.w    $16(a4)
  292.     rts
  293.  
  294. mt_port:move.b    3(a4),d0
  295.     beq.s    mt_port2
  296.     move.b    d0,$15(a4)
  297.     clr.b    3(a4)
  298. mt_port2:
  299.     tst.w    $16(a4)
  300.     beq.s    mt_rts
  301.     moveq    #0,d0
  302.     move.b    $15(a4),d0
  303.     tst.b    $14(a4)
  304.     bne.s    mt_sub
  305.     add.w    d0,$10(a4)
  306.     move.w    $16(a4),d0
  307.     cmp.w    $10(a4),d0
  308.     bgt.s    mt_portok
  309.     move.w    $16(a4),$10(a4)
  310.     clr.w    $16(a4)
  311. mt_portok:
  312.     move.w    $10(a4),6(a5)
  313. mt_rts:    rts
  314.  
  315. mt_sub:    sub.w    d0,$10(a4)
  316.     move.w    $16(a4),d0
  317.     cmp.w    $10(a4),d0
  318.     blt.s    mt_portok
  319.     move.w    $16(a4),$10(a4)
  320.     clr.w    $16(a4)
  321.     move.w    $10(a4),6(a5)
  322.     rts
  323.  
  324. mt_sin:
  325.     dc.b $00,$18,$31,$4a,$61,$78,$8d,$a1,$b4,$c5,$d4,$e0,$eb,$f4,$fa,$fd
  326.     dc.b $ff,$fd,$fa,$f4,$eb,$e0,$d4,$c5,$b4,$a1,$8d,$78,$61,$4a,$31,$18
  327.  
  328. mt_vib:    move.b    $3(a4),d0
  329.     beq.s    mt_vib2
  330.     move.b    d0,$18(a4)
  331.  
  332. mt_vib2:move.b    $19(a4),d0
  333.     lsr.w    #2,d0
  334.     and.w    #$1f,d0
  335.     moveq    #0,d2
  336.     move.b    mt_sin(pc,d0.w),d2
  337.     move.b    $18(a4),d0
  338.     and.w    #$f,d0
  339.     mulu    d0,d2
  340.     lsr.w    #7,d2
  341.     move.w    $10(a4),d0
  342.     tst.b    $19(a4)
  343.     bmi.s    mt_vibsub
  344.     add.w    d2,d0
  345.     bra.s    mt_vib3
  346. mt_vibsub:
  347.     sub.w    d2,d0
  348. mt_vib3:move.w    d0,6(a5)
  349.     move.b    $18(a4),d0
  350.     lsr.w    #2,d0
  351.     and.w    #$3c,d0
  352.     add.b    d0,$19(a4)
  353.     rts
  354.  
  355.  
  356. mt_arplist:
  357.     dc.b 0,1,2,0,1,2,0,1,2,0,1,2,0,1,2,0,1,2,0,1,2,0,1,2,0,1,2,0,1,2,0,1
  358.  
  359. mt_arp:    moveq    #0,d0
  360.     move.b    mt_counter(pc),d0
  361.     move.b    mt_arplist(pc,d0.w),d0
  362.     beq.s    mt_arp0
  363.     cmp.b    #2,d0
  364.     beq.s    mt_arp2
  365. mt_arp1:moveq    #0,d0
  366.     move.b    3(a4),d0
  367.     lsr.b    #4,d0
  368.     bra.s    mt_arpdo
  369. mt_arp2:moveq    #0,d0
  370.     move.b    3(a4),d0
  371.     and.b    #$f,d0
  372. mt_arpdo:
  373.     asl.w    #1,d0
  374.     move.w    $10(a4),d1
  375.     and.w    #$fff,d1
  376.     lea    mt_periods(pc),a0
  377.     moveq    #$24,d2
  378. mt_arp3:cmp.w    (a0)+,d1
  379.     bge.s    mt_arpfound
  380.     dbf    d2,mt_arp3
  381. mt_arp0:move.w    $10(a4),6(a5)
  382.     rts
  383. mt_arpfound:
  384.     move.w    -2(a0,d0.w),6(a5)
  385.     rts
  386.  
  387. mt_normper:
  388.     move.w    $10(a4),6(a5)
  389.     rts
  390.  
  391. mt_com:    move.w    2(a4),d0
  392.     and.w    #$fff,d0
  393.     beq.s    mt_normper
  394.     move.b    2(a4),d0
  395.     and.b    #$f,d0
  396.     tst.b    d0
  397.     beq.s    mt_arp
  398.     cmp.b    #1,d0
  399.     beq.s    mt_portup
  400.     cmp.b    #2,d0
  401.     beq.s    mt_portdown
  402.     cmp.b    #3,d0
  403.     beq    mt_port
  404.     cmp.b    #4,d0
  405.     beq    mt_vib
  406.     cmp.b    #5,d0
  407.     beq.s    mt_volport
  408.     cmp.b    #6,d0
  409.     beq.s    mt_volvib
  410.     move.w    $10(a4),6(a5)
  411.     cmp.b    #$a,d0
  412.     beq.s    mt_volslide
  413.     rts
  414.  
  415. mt_portup:
  416.     moveq    #0,d0
  417.     move.b    3(a4),d0
  418.     sub.w    d0,$10(a4)
  419.     move.w    $10(a4),d0
  420.     cmp.w    #$71,d0
  421.     bpl.s    mt_portup2
  422.     move.w    #$71,$10(a4)
  423. mt_portup2:
  424.     move.w    $10(a4),6(a5)
  425.     rts
  426.  
  427. mt_portdown:
  428.     moveq    #0,d0
  429.     move.b    3(a4),d0
  430.     add.w    d0,$10(a4)
  431.     move.w    $10(a4),d0
  432.     cmp.w    #$358,d0
  433.     bmi.s    mt_portdown2
  434.     move.w    #$358,$10(a4)
  435. mt_portdown2:
  436.     move.w    $10(a4),6(a5)
  437.     rts
  438.  
  439. mt_volvib:
  440.      bsr    mt_vib2
  441.      bra.s    mt_volslide
  442. mt_volport:
  443.      bsr    mt_port2
  444.  
  445. mt_volslide:
  446.     moveq    #0,d0
  447.     move.b    3(a4),d0
  448.     lsr.b    #4,d0
  449.     beq.s    mt_vol3
  450.     add.b    d0,$13(a4)
  451.     cmp.b    #$40,$13(a4)
  452.     bmi.s    mt_vol2
  453.     move.b    #$40,$13(a4)
  454. mt_vol2:moveq    #0,d0
  455.     move.b    $13(a4),d0
  456.     move.w    d0,8(a5)
  457.     rts
  458.  
  459. mt_vol3:move.b    3(a4),d0
  460.     and.b    #$f,d0
  461.     sub.b    d0,$13(a4)
  462.     bpl.s    mt_vol4
  463.     clr.b    $13(a4)
  464. mt_vol4:moveq    #0,d0
  465.     move.b    $13(a4),d0
  466.     move.w    d0,8(a5)
  467.     rts
  468.  
  469. mt_com2:move.b    $2(a4),d0
  470.     and.b    #$f,d0
  471.     cmp.b    #$e,d0
  472.     beq.s    mt_filter
  473.     cmp.b    #$d,d0
  474.     beq.s    mt_pattbreak
  475.     cmp.b    #$b,d0
  476.     beq.s    mt_songjmp
  477.     cmp.b    #$c,d0
  478.     beq.s    mt_setvol
  479.     cmp.b    #$f,d0
  480.     beq.s    mt_setspeed
  481.     rts
  482.  
  483. mt_filter:
  484.     move.b    3(a4),d0
  485.     and.b    #1,d0
  486.     asl.b    #1,d0
  487.     and.b    #$fd,$bfe001
  488.     or.b    d0,$bfe001
  489.     rts
  490.  
  491. mt_pattbreak:
  492.     move.b    #1,mt_break
  493.     rts
  494.  
  495. mt_songjmp:
  496.     move.b    #1,mt_break
  497.     move.b    3(a4),d0
  498.     subq.b    #1,d0
  499.     move.b    d0,mt_songpos
  500.     rts
  501.  
  502. mt_setvol:
  503.     cmp.b    #$40,3(a4)
  504.     bls.s    mt_sv2
  505.     move.b    #$40,3(a4)
  506. mt_sv2:    moveq    #0,d0
  507.     move.b    3(a4),d0
  508.     move.b    d0,$13(a4)
  509.     move.w    d0,8(a5)
  510.     rts
  511.  
  512. mt_setspeed:
  513.     moveq    #0,d0
  514.     move.b    3(a4),d0
  515.     cmp.b    #$1f,d0
  516.     bls.s    mt_sp2
  517.     moveq    #$1f,d0
  518. mt_sp2:    tst.w    d0
  519.     bne.s    mt_sp3
  520.     moveq    #1,d0
  521. mt_sp3:    move.b    d0,mt_speed
  522.     rts
  523.  
  524. mt_periods:
  525.     dc.w $0358,$0328,$02fa,$02d0,$02a6,$0280,$025c,$023a,$021a,$01fc,$01e0
  526.     dc.w $01c5,$01ac,$0194,$017d,$0168,$0153,$0140,$012e,$011d,$010d,$00fe
  527.     dc.w $00f0,$00e2,$00d6,$00ca,$00be,$00b4,$00aa,$00a0,$0097,$008f,$0087
  528.     dc.w $007f,$0078,$0071,$0000
  529.  
  530. mt_speed:    dc.b    6
  531. mt_counter:    dc.b    0
  532. mt_pattpos:    dc.w    0
  533. mt_songpos:    dc.b    0
  534. mt_break:    dc.b    0
  535. mt_dmacon:    dc.w    0
  536. mt_samplestarts:dcb.l    $1f,0
  537. mt_voice1:    dcb.w    13,0
  538.         dc.w    1
  539. mt_voice2:    dcb.w    13,0
  540.         dc.w    2
  541. mt_voice3:    dcb.w    13,0
  542.         dc.w    4
  543. mt_voice4:    dcb.w    13,0
  544.         dc.w    8
  545.  
  546. ;
  547. ;
  548.     SECTION Module,Data_c
  549. ;
  550. ;
  551.  
  552. mt_data
  553.     incbin    "mod.xxx"            ; include a NoiseTracker module here !
  554.  
  555.     dc.l    "KILL"                ; old NT-routine bug!! (not existent in
  556.                         ; the internal NT replay routine)
  557.  
  558.